﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="QuickSearch.ascx.cs" Inherits="UserControls_QuickSearch" %>

    <script language="javascript" type="text/javascript">
        var _LandPropertyTypeID = '<%=ConfigReader.LandPropertyTypeID %>';        
        function SearchProjects() {
            var url = '/Pages/Public/ProjectList.aspx?';
            var propertyTypeID = $('#<%=ddlType.ClientID %>').val();
            var statusID = '';
            if (propertyTypeID.indexOf('-') > -1) {
                var parts = propertyTypeID.split('-');
                propertyTypeID = parts[0];
                statusID = parts[1];
            }
            url += '<%=AppConstants.QueryString.PROPERTY_TYPE_ID %>=' + propertyTypeID;
            if (_LandPropertyTypeID == $('#<%=ddlType.ClientID %>').val()) {
                url += '&<%=AppConstants.QueryString.SIZE_FROM %>=' + $('#<%=ddlLandSizeFrom.ClientID %>').val()
                    + '&<%=AppConstants.QueryString.SIZE_TO %>=' + $('#<%=ddlLandSizeTo.ClientID %>').val();
            }
            else {
                url += '&<%=AppConstants.QueryString.SIZE_FROM %>=' + $('#<%=ddlSize.ClientID %>').val()
                    + '&<%=AppConstants.QueryString.SIZE_TO %>=' + $('#<%=ddlSizeTo.ClientID %>').val();
            }
            url += '&<%=AppConstants.QueryString.CITY_ID %>=' + $('#<%=ddlLocation.ClientID %>').val()
            if (statusID.length > 0)
                url += '&<%=AppConstants.QueryString.STATUS_ID %>=' + statusID;
            window.location = url + '&Rnd=' + GetRandomNumber();
        }

        function SearchContent() {
            if ($('#tblTabSearch_0').is(':visible'))
                SearchProjects();
            else if ($('#tblTabSearch_1').is(':visible')) {
                var url = '/Pages/Public/RentSearch.aspx?<%=AppConstants.QueryString.CITY_ID %>=' + $('#<%=ddlRentCountry.ClientID %>').val() + '&<%=AppConstants.QueryString.ZONE_ID %>=' + $('#<%=ddlRentZone.ClientID %>').val() + '&<%=AppConstants.QueryString.FROM_TO %>=' + $('#<%=ddlBedsFrom.ClientID %>').val() + '-' + $('#<%=ddlBedsTo.ClientID %>').val();
                window.location = url + '&Rnd=' + GetRandomNumber();
            }
            else if ($('#tblTabSearch_2').is(':visible')) {
                var url = '/Pages/Public/CompanySearch.aspx?<%=AppConstants.QueryString.KEY %>=' + $('#<%=txtKeyword.ClientID %>').val() + '&<%=AppConstants.QueryString.PACKAGE_TYPE %>=' + $('#<%=ddlSubscriptionTypes.ClientID %>').val() + '&Rnd=' + GetRandomNumber();
                window.location = url;
            }
        }

        var _CurrentTabIndex = -1;
        function ShowTab(divElement, tabIndex) {
            if (tabIndex != _CurrentTabIndex) {
                _CurrentTabIndex = tabIndex;
                $('.TabContainer').hide();
                ///Remove all Selected Image
                $('#tblTabContainer div').each(function (i) {
                    var className = $(this).attr('SelectedCssClass') + '_Not';
                    $(this).attr('class', className)
                });
                $('#tblTabSearch_' + tabIndex).show();
                ///Set Selected Tab
                $(divElement).attr('class', $(divElement).attr('SelectedCssClass'));
            }
        }

        $(document).ready(function () {
            ShowTab($('#tblTabContainer div')[0], 0);
            $('#<%=ddlType.ClientID %>').change(function () {
                if (_LandPropertyTypeID == $('#<%=ddlType.ClientID %>').val()) {
                    $('#<%=ddlSize.ClientID %>').hide();
                    $('#<%=ddlSizeTo.ClientID %>').hide();
                    $('#<%=ddlLandSizeFrom.ClientID %>').show();
                    $('#<%=ddlLandSizeTo.ClientID %>').show();
                }
                else {
                    $('#<%=ddlSize.ClientID %>').show();
                    $('#<%=ddlSizeTo.ClientID %>').show();
                    $('#<%=ddlLandSizeFrom.ClientID %>').hide();
                    $('#<%=ddlLandSizeTo.ClientID %>').hide();
                }
            });
            $('#<%=ddlRentCountry.ClientID %>').change(function () {
                BindZoneWithDropdownList($('#<%=ddlRentCountry.ClientID %>'), $('#<%=ddlRentZone.ClientID %>'));
            });            
        });
    </script>


    <div>
        <div <%if(ShowGroupBorder){ %> style="margin-left:15px;"<%} %>>            
            <table id="tblTabContainer" cellpadding="0" cellspacing="0">
                <tr>                                
                    <td><div onclick="ShowTab(this, 0);" class='QuickSearchTab' SelectedCssClass="QuickSearchTab"><%--For Sell--%>Flat</div></td>
                    <td><div onclick="ShowTab(this, 1);" class='QuickSearchTab_Not' SelectedCssClass="QuickSearchTab"><%--To Rent--%>Rent</div></td>
                    <td><div onclick="ShowTab(this, 2);" class='QuickSearchTab_Not' SelectedCssClass="QuickSearchTab">Company</div></td>                                
                </tr>
            </table>
        </div>
        <%--Quick Search Tab Section End--%>
                
        <div <%if(ShowGroupBorder){ %> class="GroupBox" style="margin-top:0px;"<%} %>>
            <%--Project Search Tab Starts--%>
            <table id="tblTabSearch_0" class="TabContainer" cellpadding="3" cellspacing="0" style="display:none;">
                <colgroup>
                    <%--<col style="width:20%;" />
                    <col style="width:30%;" />
                    <col style="width:10%;" />
                    <col />--%>
                    <col style="width:20%;" />                            
                    <col />
                    <col /> 
                    <col />
                </colgroup>
                <tr>
                    <td><asp:Label ID="lblType" runat="server" Text="Type"></asp:Label></td>
                    <td colspan="3"><asp:DropDownList ID="ddlType" runat="server" CssClass="BigBropDownList"></asp:DropDownList></td>
                </tr>
                <tr>
                    <td><asp:Label ID="lblSize" runat="server" Text="Size"></asp:Label></td>
                    <td>
                        <asp:DropDownList ID="ddlSize" runat="server" CssClass="BigBropDownList"></asp:DropDownList>
                        <asp:DropDownList ID="ddlLandSizeFrom" runat="server" CssClass="BigBropDownList" style="display:none;"></asp:DropDownList>                                    
                    </td>
                    <td><asp:Label ID="lblSizeTo" runat="server" Text="To"></asp:Label></td>
                    <td>
                        <asp:DropDownList ID="ddlSizeTo" runat="server" CssClass="BigBropDownList"></asp:DropDownList>
                        <asp:DropDownList ID="ddlLandSizeTo" runat="server" CssClass="BigBropDownList" style="display:none;"></asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td><asp:Label ID="lblLocation" runat="server" Text="Location"></asp:Label></td>
                    <td colspan="3"><asp:DropDownListX ID="ddlLocation" runat="server" CssClass="BigBropDownList"></asp:DropDownListX></td>
                </tr>                    
            </table>
            <%--Project Search Tab Ends--%>
                    
            <%-- Rent Search Tab Start --%>
            <table id="tblTabSearch_1" class="TabContainer" cellpadding="3" cellspacing="0">
                <colgroup>
                    <col style="width:20%;" />                            
                    <col />
                    <col /> 
                    <col />
                </colgroup>
                <tr>
                    <td><asp:Label ID="Label1" runat="server" Text="Beds"></asp:Label></td>
                    <td>
                        <asp:DropDownList ID="ddlBedsFrom" runat="server" CssClass="BigBropDownList">
                            <asp:ListItem Text="1" Value="1"></asp:ListItem>
                            <asp:ListItem Text="2" Value="2"></asp:ListItem>
                            <asp:ListItem Text="3" Value="3"></asp:ListItem>
                            <asp:ListItem Text="4" Value="4"></asp:ListItem>
                            <asp:ListItem Text="5" Value="5"></asp:ListItem>
                            <asp:ListItem Text="More" Value="6"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td>To</td>
                    <td>
                        <asp:DropDownList ID="ddlBedsTo" runat="server" CssClass="BigBropDownList">
                            <asp:ListItem Text="1" Value="1"></asp:ListItem>
                            <asp:ListItem Text="2" Value="2"></asp:ListItem>
                            <asp:ListItem Text="3" Value="3"></asp:ListItem>
                            <asp:ListItem Text="4" Value="4"></asp:ListItem>
                            <asp:ListItem Text="5" Value="5"></asp:ListItem>
                            <asp:ListItem Text="More" Value="6"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td><asp:Label ID="Label2" runat="server" Text="City"></asp:Label></td>
                    <td colspan="3">
                        <asp:DropDownListX ID="ddlRentCountry" runat="server" CssClass="BigBropDownList"></asp:DropDownListX>                                
                    </td>                            
                </tr>             
                <tr>                            
                    <td><asp:Label ID="lblRentZone" runat="server" Text="Zone"></asp:Label></td>
                    <td colspan="3">
                        <asp:DropDownList ID="ddlRentZone" runat="server" CssClass="BigBropDownList">
                            <asp:ListItem Text="" Value=""></asp:ListItem>
                        </asp:DropDownList>
                    </td>                            
                </tr>                            
            </table>    
            <%-- Rent Search Tab Ends --%>
                    
            <%--Company Search Tab--%>
            <table id="tblTabSearch_2" class="TabContainer" cellpadding="3" cellspacing="0">
                <colgroup>
                    <col style="width:20%;" />
                    <col />
                </colgroup>
                <tr>
                    <td>Keyword</td>
                    <td><asp:TextBox ID="txtKeyword" runat="server" CssClass="BigBropDownList" MaxLength="150"></asp:TextBox></td>
                </tr>
                <tr>
                    <td>Subscription Type</td>
                    <td><asp:DropDownList ID="ddlSubscriptionTypes" CssClass="BigBropDownList" runat="server"></asp:DropDownList></td>
                </tr>                                       
            </table>                   
            <%--Company Search Tab Ends--%>
                    
            <div class="clearboth"></div> 
            <div>
                <div class="SeachButton" onclick="SearchContent();"></div>
                <div class="clearboth"></div>
                <%--<div style="margin-top:11px;margin-left:20px;padding-top:0px;border:0;text-align:right;padding-right:5px;">
                    <%if (ShowAdvancedSearchLink)
                      { %>
                      <a href="/Pages/Public/AdvanceSearch.aspx">Advanced Search</a>
                    <%} %>
                </div>   --%>                        
            </div>
        </div>
    </div>